#include <QtGui/QApplication>
#include <QTextCodec>
#include "src/gui/qt/mainwindow.h"
#include "src/core/generic/translator.h"
#include "src/core/mvc/controller.h"
#include "src/core/mvc/model.h"

Translator translator;

#include <QFile>
#include <QString>

std::istringstream _def_atom_parameters_xml_; // todo: think of changing QT way of inner storing XML

int main(int argc, char *argv[])
{
  QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
  QApplication a(argc, argv);

  QFile atomParametersDefaultXmlFile(":/atomparameters.xml");
  atomParametersDefaultXmlFile.open(QIODevice::ReadOnly);
  QString atomParametersDefaultXmlFileContents(atomParametersDefaultXmlFile.readAll());
  std::string atomParametersDefaultXmlFileContentsStd(atomParametersDefaultXmlFileContents.toStdString());
  _def_atom_parameters_xml_.str(atomParametersDefaultXmlFileContentsStd);

  View *view = new MainWindow;
  Model model;
  Controller controller;

  controller.setModel(&model);
  controller.setView(view);
  model.setController(&controller);
  view->setController(&controller);
  model.loadVizParameters();

  ( (MainWindow *) view)->show();
  return a.exec();
}
